angular.module('enrolllistcontrollers',[])
  //发现的首页（约局）的Controller
  .controller('ApplyMemberCtrl',function($scope,$state,$stateParams,ENV,Meeting,Storage,History){

    var mmId = $stateParams['mmId'];
    var memberId = '';
    $scope.picPath = ENV.picPath;

    $scope.$on('$ionicView.beforeEnter', function () {
      memberId = Storage.get("member").member_id;
    })
    $scope.phoneCall = function(phoneNum){
      if(phoneNum!=undefined&&phoneNum!=''){
        if(ionic.Platform.isAndroid()){
          document.location.href = "tel:"+phoneNum;
        }else if(ionic.Platform.isIOS()){
          phonedialer.dial(phoneNum,function(err) {
            if (err == "feature")
              console.log("您的设备不支持");
            if (err == "empty")
              Toast.showMessage("未知的电话号码");
          });
        }
      }else{
        Toast.showMessage("号码不存在");
      }
    }
    Meeting.getSignInPersionList(mmId);//重新获取报名列表
    //网络访问请求成功的之后
    $scope.$on('Meeting.signInPersionListUpdated',function(){
      var result = Meeting.getSignInPersionListJson();
      $scope.applyMemberList = result.personList;
      var mmMemberId = result.mm_member_id;
      if(memberId==mmMemberId){
        $scope.isSelf = true;
      }
    })
    //返回
    $scope.goback = function(){
      History.goback();
    }

    //点击头像跳转到用户的个人信息
    $scope.go2MemberInfo = function(memberId){
      $state.go('member-data',{'memberId':memberId});
    }
  })
//发现的首页（约局）的Controller
  .controller('MemberDataCtrl',function($scope,$stateParams,MeMyData,ENV,Loading,History){
       var memberId = $stateParams['memberId'];
        $scope.picPath = ENV.picPath;
        MeMyData.getMeInfo(memberId);
        Loading.showLoading();

    $scope.$on('Me.meInfo',function(){
      $scope.memberData = MeMyData.getMeInfoJson();
      Loading.hideLoading();
    });
    $scope.goback = function(){
      History.goback();
    }
  });
